﻿/*
 
Celerity: Sensory Overload
Copright 2012 by Adam Hill, David Gannon, Thomas Tamblyn & Patrick Ytting
Contact: adam.hill@outlook.com
Website: adamhill.org
Licence: MS-Pl Licence
  
 */

namespace Celerity.Util
{
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;

    public static class GraphicsDeviceUtil
    {
        // Resolutions we need to support: (Intel devices are tested for these *)
        //2560x1600
        //1920x1200
        //1920x1080
        //1600x900*
        //1440x900*
        //1366x768*
        //1024x600*

        public static GraphicsDeviceManager Create(Game game)
        {
            // Set up Application & Window
            game.Window.AllowUserResizing = false;
            game.Window.Title = CeleritySettings.WindowTitle;

            if (!CeleritySettings.OverrideWindowSize)
            {
                int height = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                int width = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                CeleritySettings.WindowWidth = width;
                CeleritySettings.WindowHeight = height;
            }

            var graphics = new GraphicsDeviceManager(game)
            {
                PreferredBackBufferWidth = CeleritySettings.WindowWidth,
                PreferredBackBufferHeight = CeleritySettings.WindowHeight,
                IsFullScreen = CeleritySettings.IsFullScreen,
            };
            graphics.ApplyChanges();
            return graphics;
        }
    }
}
